<!DOCTYPE html>
<html lang="en">
<head>
    {include file="Public/header"}
</head>
<body>
<div class="ibox">
    <div class="ibox-title">
        <h2 class="title_color text-center">请选择办理人</h2>
    </div>
    <div class="ibox-content">
        <form action="" method="post" id="form1">
            <table class="table">
                <tr>
                    <td style="width:20%;">
                        <label for="">办理人</label>
                    </td>
                    <td>

                        <div class="input-group" id="cusName_input">
                            <input type="text" placeholder="请输入关键字或空格查询" class="form-control" id="cusName" >
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                        <div id="cusName_queding" class="selectedOnlyOne" style="display: none;">
                            <input type="hidden" name="Author" value="">
                            <span class="inin"></span>
                            <span class="close">×</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="hidden" name="type" value="1">
                        <input type="hidden" name="data" value='{:json_encode($data)}'>
                        <input type="hidden" name="spyj" value='{$spyj}'>
                        <input type="hidden" name="nodeId" value="{:request()->post('nodeId')}">
                        <input type="submit" value="提交">
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
</body>
{include file="Public/footer"}
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script>
    $(function () {
        $("#cusName").bsSuggest({
            url: '{:url("blr")}',
            effectiveFields: ["id", "em_name"],
            searchFields: [ "em_name"],
            effectiveFieldsAlias: {em_name: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "em_name",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword) {
            $('#cusName_queding').find('.inin').html(keyword.key)
            $('#cusName_queding').find('input').val(keyword.id)
            $('#cusName_queding').show()
            $('#cusName_input').hide()

        }).on('onUnsetSelectValue', function () {
            console.log("onUnsetSelectValue");
        });

        //关闭经销商选择
        $('#cusName_queding .close').click(function () {
            $(this).closest('#cusName_queding').hide().find('.inin').html('')
            $('#cusName_input').show().find('input').val('')
        })
    })
</script>
</html>